package com.hb.order.controller;

import com.hb.order.annotation.MethodLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Autowired
    RestTemplate restTemplate;

    @MethodLog
    @RequestMapping("/add")
    public String add() {
        //System.out.println("下单成功！");
        log.info("下单成功！");
        //this.testAopAnotation();
        String msg = restTemplate.getForObject("http://localhost:8011/stock/reduct", String.class);
        return "hello world " + msg;
    }

    @MethodLog
    public String testAopAnotation () {
        System.out.println("testAopAnotation");
        return "testAopAnotation";
    }
}
